/**
 * Created by frank on 2017/9/11.
 */
;(function(window){
   //封闭的私用变量
    var $id = function(id){
        if (typeof id === 'object') {
            return id;
        } else {
            return document.getElementById(id);
        }
    },
        $tag = function(tagName){
            return document.getElementsByTagName(tagName);
        };

   //相当于var id=10,tag=20;
    // var id = 10;
    // var tag = 20;

    var myFocus = function(setting){
            return new myFocus.constr(setting);
    };

    //extend 扩充这个对象的属性
    myFocus.extend = function(){//{a:'frank',b:'tom',c:function(){}}
        var dest = myFocus;
        for(var i in arguments){
            for(var item in arguments[i]){
                dest[item] = arguments[i][item];
            }
        }
    }

    //静态属性
    myFocus.extend({
        constr:function(setting){
            this.ball = document.getElementById(setting.ballid);
            this.btn = document.getElementById(setting.clickbtn);
            this.bEvent();
        },
        set:function(setting){
            var obj =  myFocus(setting);;

        }
    });

    myFocus.fn = myFocus.constr.prototype;
    myFocus.fn.extend = function(){//{a:'frank',b:'tom',c:function(){}}
        var dest = myFocus.fn;
        for(var i in arguments){
            for(var item in arguments[i]){
                dest[item] = arguments[i][item];
            }
        }
    }

    //原型对象中的属性
    myFocus.fn.extend({
        bEvent:function(){
            this.btn.onclick = this.move;
        },
        move:function(){
           function domove(){
               this.ball.style.marginLeft = parseInt(this.ball.style.marginLeft)+5+'px';
           }
           this.t = setInterval(domove,20);
        }
    })




    window.myFocus = myFocus;


})(window);